package cn.iocoder.yudao.module.member.alliance.controller.app;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.alliance.service.CloudAlliancePackageService;
import cn.iocoder.yudao.module.member.alliance.vo.CloudAlliancePackageVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.annotation.security.PermitAll;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;

@Tag(name = "用户 APP - 云盟商身份套餐")
@RestController
@RequestMapping("/member/cloud-alliance-package")
@Validated
public class AppCloudAlliancePackageController {

    @Resource
    private CloudAlliancePackageService cloudAlliancePackageService;

    @GetMapping("/top1")
    @Operation(summary = "获得一个套餐")
    @PermitAll
    public CommonResult<CloudAlliancePackageVO> getOne() {
        return success(cloudAlliancePackageService.getOne(getLoginUserId()));
    }

    @GetMapping("/list")
    @Operation(summary = "获得套餐列表")
    @Parameter(name = "limit", description = "数据条数", required = true, example = "3")
    @PermitAll
    public CommonResult<List<CloudAlliancePackageVO>> getList(@RequestParam(value = "limit", required = false, defaultValue = "3") Integer limit) {
        return success(cloudAlliancePackageService.getList(getLoginUserId(), limit));
    }

}